﻿using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using ReflectionStudio.Core.Events;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for ProductionOrder.xaml
    /// </summary>
    public partial class UIKUNDVER : ViewBase
    {
        public VKUNDVER TMV
        {
            get
            {
                return (VKUNDVER)MV;
            }
        }
        #region ==KUNDNR===========
        public static readonly DependencyProperty KUNDNRProperty = DependencyProperty.Register("KUNDNR",
            typeof(string), typeof(UIKUNDVER),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnKUNDNRChanged));
        public string KUNDNR
        {
            get
            {
                return (string)GetValue(KUNDNRProperty);
            }
            set
            {
                SetValue(KUNDNRProperty, value);
                OnKUNDNRChg(value);
            }
        }
        private static void OnKUNDNRChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIKUNDVER;
            if (src != null)
            {
                src.KUNDNR = (string)e.NewValue;
            }
        }
        #endregion


        #region ==ZAHLBED===========
        public static readonly DependencyProperty ZAHLBEDProperty = DependencyProperty.Register("ZAHLBED",
            typeof(string), typeof(UIKUNDVER),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnZAHLBEDChanged));
        public string ZAHLBED
        {
            get
            {
                return (string)GetValue(ZAHLBEDProperty);
            }
            set
            {
                SetValue(ZAHLBEDProperty, value);
                if (!IsEdit)
                    return;
                TMV.KDVZAHLBED = value;

            }
        }
        private static void OnZAHLBEDChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIKUNDVER;
            if (src != null)
            {
                src.ZAHLBED = (string)e.NewValue;
            }
        }
        #endregion

        #region ==STEUER===========
        public static readonly DependencyProperty STEUERProperty = DependencyProperty.Register("STEUER",
            typeof(string), typeof(UIKUNDVER),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnSTEUERChanged));
        public string STEUER
        {
            get
            {
                return (string)GetValue(STEUERProperty);
            }
            set
            {
                SetValue(STEUERProperty, value);
                if (!IsEdit)
                    return; 
                TMV.KDVSTEUER = value; 
            }
        }
        private static void OnSTEUERChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIKUNDVER;
            if (src != null)
            {
                src.STEUER = (string)e.NewValue;
            }
        }
        #endregion

        #region ==VB===========
        public static readonly DependencyProperty VBProperty = DependencyProperty.Register("VB",
        typeof(string), typeof(UIKUNDVER),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnVBChanged));
        public string VB
        {
            get
            {
                return (string)GetValue(VBProperty);
            }
            set
            {
                SetValue(VBProperty, value);
            }
        }
        private static void OnVBChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIKUNDVER;
            if (src != null)
            {
                src.VB = (string)e.NewValue;
            }
        }
        #endregion

        #region ==VG===========
        public static readonly DependencyProperty VGProperty = DependencyProperty.Register("VG",
        typeof(string), typeof(UIKUNDVER),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnVGChanged));
        public string VG
        {
            get
            {
                return (string)GetValue(VGProperty);
            }
            set
            {
                SetValue(VGProperty, value);
            }
        }
        private static void OnVGChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIKUNDVER;
            if (src != null)
            {
                src.VG = (string)e.NewValue;
            }
        }
        #endregion

        #region ==LIEFBED===========
        public static readonly DependencyProperty LIEFBEDProperty = DependencyProperty.Register("LIEFBED",
        typeof(string), typeof(UIKUNDVER),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnLIEFBEDChanged));
        public string LIEFBED
        {
            get
            {
                return (string)GetValue(LIEFBEDProperty);
            }
            set
            {
                SetValue(LIEFBEDProperty, value);
                if (!IsEdit)
                    return;
                TMV.KDVLIEFBED = value;
            }
        }
        private static void OnLIEFBEDChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIKUNDVER;
            if (src != null)
            {
                src.LIEFBED = (string)e.NewValue;
            }
        }
        #endregion


        public UIKUNDVER()
        {
        }

        public virtual void OnKUNDNRChg(string value)
        {

        }
        public override void OnAppModeChg()
        {
            base.OnAppModeChg();

            switch (app.company)
            {
                case "TST":
                    VB = "   ";
                    switch (app.AppMode)
                    {
                        case "TISSUE":
                            //VB = "TSK";
                            break;
                        case "TMODE":
                            //VB = "TMK";
                            break;
                    }
                    break;
            }
        }

    }
}
